pp108 : uploadFile Method

uploadFile Method


This method uploads the files to an application connector or a server.

Syntax

uploadID.uploadFile(formElement)

Return Value


No return value.

Remarks


The method uploads the request message, which is an XML document, along with the file content to upload.wcp, which in turn sends it to gateway.wcp.

Example


The following example uploads a file.

<!-- Upload component definition -->
<div cordysType="wcp.library.util.Upload" id="uploader"/>
<!-- XML Request - To Server -->
<script type ="cordys/xml" id="request">
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP:Body>
            <Upload xmlns="http://schemas.cordys.com/1.0/devtools">
                <FileName>Upload:FileName1</FileName>
                <FileContent>Upload:FileContent1</FileContent>
            </Upload>
        </SOAP:Body>
    </SOAP:Envelope>
</script>
//Function that sets properties and calls the method
function uploadFile()
{
    uploader.fileCount = 1;
    uploader.encode = true;
    uploader.request = request.XMLDocument;
    uploader.uploadFile();
}

Uploading Large Files


When a large file is uploaded, the uploaded file is saved in a temporary folder specified by the user and this location is sent to the SOAP processor.
The following properties have to be set for this method:

  • bus.jvm.heapsize = <size in MB>: The default value is 64m. The maximum value depends on the server's settings.
  • com.eibus.web.tools.upload.UploadWritePath= <Temporary folder for uploading>: The user has to create this folder.
  • Specify Upload: FilePath as a method argument as follows:
    <uploader xmlns="http://schemas.cordys.com/UploadClient">
        <FilePath>Upload:FilePath1</FilePath>
    </uploader>
    

  • If you want to pass the actual name of the uploaded file, specifyUpload.FileName1as a method argument as follows.
    <uploader xmlns="http://schemas.cordys.com/UploadClient">
    	<FilePath>Upload:FilePath1</FilePath>
    	<FileName>Upload.FileName1</ FileName >
    </uploader>
    

    Note: Delete the file from the server after uploading. If they are not deleted, the temporary files can block a huge amount of disk space in the server. Deleting the files can be done in any of the following ways.
    • Delete the file after processing the request. This has to be done at the SOAP processor level, for which you need to have the appropriate write permission.
    • Specify the following in the response:
      <DeleteTempFile/>
      
      On receiving the above response, the upload component deletes the file from the temporary folder.

Example


The following example uploads a large file.

!-- Upload component definition -->
<div cordysType="wcp.library.util.Upload" id="uploader"/>
<!-- XML Request - To Server -->
<script type ="cordys/xml" id="requestString">
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP:Body>
            <uploader xmlns="http://schemas.cordys.com/UploadClient">
               <FilePath>Upload:FilePath1</FilePath>
               <FileName>Upload:FileName1</ FileName>
           </uploader>
        </SOAP: Body>
    </SOAP:Envelope>
</script>
//Function that sets properties and calls the method
function uploadFile()
{
    uploader.fileCount = 1;
    uploader.encode = true;
    uploader.request = requestString.XMLdocument;
    uploader.uploadFile();
}

Uploading Multiple Files


When multiple files have to be uploaded, theuploader.fileCountattribute has to be set to the number of files that will be uploaded.

Example


The following example uploads three files.

!-- Upload component definition --> 
<div cordysType="wcp.library.util.Upload" id="uploader"/>
<!-- XML Request - To Server -->
<script type ="cordys/xml" id="requestString">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Body>
        <UploadFiles xmlns="http://schemas.cordys.com/1.0/uploadfiles">
            <files>
                <file>
                    <FileName>Upload:FileName1</FileName>
                    <FileContent>Upload:FileContent1</FileContent>
                </file>
                <file>
                    <FileName>Upload:FileName2</FileName>
                    <FileContent>Upload:FileContent2</FileContent>
                </file>
                <file>
                    <FileName>Upload:FileName3</FileName>
                    <FileContent>Upload:FileContent3</FileContent>
                </file>
            </files>
        </UploadFiles>
    </SOAP:Body>
</SOAP:Envelope> 
</script> 

//Function that sets properties and calls the method 
function uploadFiles() 
{
    uploader.fileCount = 3;
    uploader.encode = true;
    uploader.request = requestString.XMLdocument;
    uploader.uploadFile(); 
}

See Also


upload

Related reference

Upload
onAfterBrowse
onBeforeUpload
browse Operation
onupload Event
request Property